package main

import (
	"encoding/json"
	"go-middleware-demo/middleware"
	"net/http"
	"time"
)

type Character struct {
	Name string  `json:"name"`
	Age  float64 `json:"age"`
}

func main() {
	http.HandleFunc("/home", func(w http.ResponseWriter, r *http.Request) {
		c := Character{
			Name: "zhangsan",
			Age:  16,
		}
		time.Sleep(4 * time.Second)

		enc := json.NewEncoder(w)
		enc.Encode(c)
	})
	// http.ListenAndServe("localhost:8080", nil)
	http.ListenAndServe("localhost:8080", &middleware.TimeOut{Next: new(middleware.AuthMiddleware)})
}
